/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityBeans;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author BELALOUACHE
 */
@Entity
@Table(name = "products")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Products.findAll", query = "SELECT p FROM Products p"),
    @NamedQuery(name = "Products.findByReferenceProd", query = "SELECT p FROM Products p WHERE p.referenceProd = :referenceProd"),
    @NamedQuery(name = "Products.findByNameProd", query = "SELECT p FROM Products p WHERE p.nameProd = :nameProd"),
    @NamedQuery(name = "Products.findByPriceProd", query = "SELECT p FROM Products p WHERE p.priceProd = :priceProd")})

public class Products implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "reference_prod")
    private Integer referenceProd;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "name_prod")
    private String nameProd;
    @Basic(optional = false)
    @NotNull
    @Column(name = "price_prod")
    private double priceProd;
    @JoinColumn(name = "id_category_fk", referencedColumnName = "id_category")
    @ManyToOne(optional = false)
    private Category idCategoryFk;
    @JoinColumn(name = "id_productsstore_fk", referencedColumnName = "reference_store")
    @ManyToOne(optional = false)
    private Productsstore idProductsstoreFk;

    public Products() {
        super();
    }

    public Products(Integer referenceProd) {
        super();
        this.referenceProd = referenceProd;
    }

    public Products(Integer referenceProd, String nameProd, double priceProd) {
        super();
        this.referenceProd = referenceProd;
        this.nameProd = nameProd;
        this.priceProd = priceProd;
    }

    public Integer getReferenceProd() {
        return referenceProd;
    }

    public void setReferenceProd(Integer referenceProd) {
        this.referenceProd = referenceProd;
    }

    public String getNameProd() {
        return nameProd;
    }

    public void setNameProd(String nameProd) {
        this.nameProd = nameProd;
    }

    public double getPriceProd() {
        return priceProd;
    }

    public void setPriceProd(double priceProd) {
        this.priceProd = priceProd;
    }

    public Category getIdCategoryFk() {
        return idCategoryFk;
    }

    public void setIdCategoryFk(Category idCategoryFk) {
        this.idCategoryFk = idCategoryFk;
    }

    public Productsstore getIdProductsstoreFk() {
        return idProductsstoreFk;
    }

    public void setIdProductsstoreFk(Productsstore idProductsstoreFk) {
        this.idProductsstoreFk = idProductsstoreFk;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (referenceProd != null ? referenceProd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Products)) {
            return false;
        }
        Products other = (Products) object;
        if ((this.referenceProd == null && other.referenceProd != null) || (this.referenceProd != null && !this.referenceProd.equals(other.referenceProd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityBeans.Products[ referenceProd=" + referenceProd + " ]";
    }
}
